import requests
import ddddocr
ocr = ddddocr.DdddOcr(show_ad=True)

count = 0
while True:
    count += 1
    print(f"正在进行第{count}次登录")

    img_res = requests.get("https://www.labnetwork.com.cn/gateway/basic/mall/oauth/code?0.5777350772751269")
    data = img_res.json()
    uuid = data['data']['uuid']
    img = data['data']['img'][22:]

    code = ocr.classification(img)
    login_res = requests.post("https://www.labnetwork.com.cn/gateway/basic/mall/oauth/login", json={
        "userEmail": "496575233@qq.com",
        "password": "pckzzy101",
        "captchaCode": f"{code}",
        "captchaKey": uuid
    })

    result = login_res.json()
    if result['status'] == 200:
        print(f"登录成功")
        token = result['data']['userInfo']['token']
        print(f"用户token{token}")
        break


# 获取我的足迹
collect_res = requests.post("https://www.labnetwork.com.cn/gateway/basic/mall/footprint/list", json={
    "page": 1,
    "limit": 12,
    "operTimestr": "",
    "productType": 1
}, headers={

    # 用户信息
    "token": token,
    # "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36",
    "referer": "https://www.labnetwork.com.cn/"
})

print(collect_res.json())